var app = getApp(), api = app.api, is_loading_more = !1, is_no_more = !1;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    tab: 0,
    mch_id: 0,
    video_list: [],
    page: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (t) {
    getApp().page.onLoad(this, t), t.mch_id && (this.data.mch_id = t.mch_id);
    this.getShopData(), this.loadMoreGoodsList(), is_no_more = is_loading_more = !1;;
  },
  
  getShopData() {
    var a = this, e = "shop_data_mch_id_" + a.data.mch_id, t = getApp().core.getStorageSync(e);
    t && a.setData({
      shop: t.shop
    }), getApp().request({
      url: getApp().api.mch.shop_info,
      data: {
        mch_id: a.data.mch_id,
      },
      success: function(e) {
        0 == e.code && a.setData({
          shop: e.data.shop,
        })
      }
    })
  },
  loadMoreGoodsList: function() {
    var t = this;
    if (!is_loading_more) {
        t.setData({
            show_loading_bar: !0,
            no_more: !1
        }), is_loading_more = !0;
        var i = t.data.page;
        app.request({
            url: api.default.video_list,
            data: {
                page: i,
                mch_id: t.data.mch_id,
                type: t.data.tab
            },
            success: function(o) {
                0 == o.data.list.length && (is_no_more = !0, t.setData({
                  no_more: !0
                }));
                var a = t.data.video_list.concat(o.data.list);
                t.setData({
                    video_list: a,
                    page: i + 1
                });
            },
            complete: function() {
                is_loading_more = !1, t.setData({
                    show_loading_bar: !1
                });
            }
        });
    }
  },
  sortClick: function(t) {
    var a = this, e = t.currentTarget.dataset.sort;
    a.setData({
        tab: e,
        page: 1,
        video_list: [],
        no_more: !1,
    }), is_loading_more = !1, is_no_more = !1, a.loadMoreGoodsList();
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    is_no_more || this.loadMoreGoodsList();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})